using System;
using System.Text;
using Rioshu.Utils.Compression.SevenZip;

namespace Rioshu.Web.ViewStateHandlers
{
    internal sealed class SevenZipCompressor : IStringCompressor
    {
        public string Compress(string input)
        {
            var buffer = Encoding.UTF8.GetBytes(input);
            buffer = SevenZipHelper.Compress(buffer);
            return Convert.ToBase64String(buffer);
        }

        public string Decompress(string input)
        {
            var buffer = Convert.FromBase64String(input);
            buffer = SevenZipHelper.Decompress(buffer);
            return Encoding.UTF8.GetString(buffer);
        }
    }
}